\defmodule{InverseGammaGen}

This class implements random variate generators for
the \emph{inverse gamma} distribution with shape parameter
$\alpha > 0$ and scale parameter $\beta > 0$.
The density function of this distribution is
\begin{htmlonly}
\eq
  f(x) = (\beta^{\alpha}\exp^{-\beta / x}) / (\Gamma(\alpha) x^{\alpha + 1})
  \qquad \mbox{for } x > 0,
\endeq
 and $f(x) = 0$ otherwise,
\end{htmlonly}
\begin{latexonly}
\eq
  f(x) = \left\{\begin{array}{ll} \displaystyle
        \frac{\beta^{\alpha}}{ \Gamma(\alpha)}
        \frac{ e^{-\beta / x}}{ x^{\alpha + 1}}
   & \quad \mbox{for } x > 0 \\[12pt]
   0  & \quad \mbox{otherwise,}
   \end{array} \right.
  \eqlabel{eq:finvgam}
\endeq
\end{latexonly}
where $\Gamma$ is the gamma function.

\bigskip\hrule

\begin{code}
\begin{hide}
/*
 * Class:        InverseGammaGen
 * Description:  random variate generators for the inverse gamma distribution 
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.randvar;
\begin{hide}
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
\end{hide}

public class InverseGammaGen extends RandomVariateGen \begin{hide} {
   protected double alpha;
   protected double beta;

\end{hide}
\end{code}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection* {Constructors}
\begin{code}

   public InverseGammaGen (RandomStream s, double alpha, double beta) \begin{hide} {
      super (s, new InverseGammaDist(alpha, beta));
      setParams(alpha, beta);
   }\end{hide}
\end{code}
\begin{tabb} Creates an inverse gamma random variate generator with parameters
  $\alpha =$ \texttt{alpha} and $\beta =$ \texttt{beta}, using stream \texttt{s}.
\end{tabb}
\begin{code}

   public InverseGammaGen (RandomStream s, double alpha) \begin{hide} {
      this (s, alpha, 1.0);
   }\end{hide}
\end{code}
\begin{tabb} Creates an inverse gamma random variate generator with parameters
 $\alpha =$ \texttt{alpha} and $\beta = 1$, using stream \texttt{s}.
\end{tabb}
\begin{code}

   public InverseGammaGen (RandomStream s, InverseGammaDist dist) \begin{hide} {
      super (s, dist);
      if (dist != null)
         setParams(dist.getAlpha(), dist.getBeta());
   }\end{hide}
\end{code}
\begin{tabb} Creates a new generator for the distribution \texttt{dist},
   using stream \texttt{s}.
\end{tabb}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
\subsubsection* {Methods}
\begin{code}

   public static double nextDouble (RandomStream s,
                                    double alpha, double beta)\begin{hide} {
      return InverseGammaDist.inverseF (alpha, beta, s.nextDouble());
   }\end{hide}
\end{code}
\begin{tabb} Generates a variate from the inverse gamma distribution
   with shape parameter $\alpha > 0$ and scale parameter $\beta > 0$.
\end{tabb}
\begin{code}

   public double getAlpha()\begin{hide} {
      return alpha;
   }\end{hide}
\end{code}
\begin{tabb} Returns the parameter $\alpha$ of this object.
\end{tabb}
\begin{code}

   public double getBeta()\begin{hide} {
      return beta;
   }\end{hide}
\end{code}
\begin{tabb} Returns the parameter $\beta$ of this object.
\end{tabb}
\begin{code}\begin{hide}

   protected void setParams (double alpha, double beta) {
      if (alpha <= 0.0)
         throw new IllegalArgumentException ("alpha <= 0");
      if (beta <= 0.0)
         throw new IllegalArgumentException ("beta <= 0");
      this.alpha = alpha;
      this.beta = beta;
   }
}\end{hide}
\end{code}
